<?php
include("template_top.php");
if(isset($_POST['s112'])){
if($_POST['s112'] == 'Yes'){
	$body =$body. "Status of machines in S-112: Working with no problems\n\n";
}else{
	$body = $body."Status of machines in S-112: Problems found\n";
	$body = $body."Description: ".$_POST['s112details']."\n\n";
}
if($_POST['fprint'] == 'Yes'){
	$body =$body. "Status of pay-for-print machine in S-112: Working with no problems\n\n";
}else{
	$body = $body."Status of free print in S-112: Problems found\n";
	$body = $body."Description: ".$_POST['fprintdetails']."\n\n";
}
if($_POST['fprintpaper'] == 'Yes'){
	$body =$body. "Was paper added to the printer in S-112: Yes\n\n";
}else{
	$body = $body."Was paper added to the free print machine: No\n";
	$body = $body."Reasoning: ".$_POST['fprintpaperdetails']."\n\n";
}
if($_POST['reg'] == 'Yes'){
	$body =$body. "Status of machines in registration: Working with no problems\n\n";
}else{
	$body = $body."Status of machines in registration: Problems found\n";
	$body = $body."Description: ".$_POST['regdetails']."\n\n";
}
if($_POST['regpaper'] == 'Yes'){
	$body =$body. "Was paper added to the printer in registration: Yes\n\n";
}else{
	$body = $body."Was paper added to the free print machine: No\n";
	$body = $body."Reasoning: ".$_POST['regpaperdetails']."\n\n";
}
if($_POST['advising'] == 'Yes'){
	$body =$body. "Status of advising machine: Working with no problems\n\n";
}else{
	$body = $body."Status of advising machine: Problems found\n";
	$body = $body."Description: ".$_POST['advisingdetails']."\n\n";
}
if($_POST['notes'] != NULL){
	$body =$body. "Notes: ".$_POST['notes'];
}
$subject = "S-Building Report For ".getCurrentDate(true);
$body = "The following S building report has been submitted.  The submission info follows.<br/>=======================================================<br/>".str_replace("\n", "<br>", $body)."Submitted By: ".$USER['sFname']." ".$USER['sLname']."<br/>=======================================================<br/><br/>This report has been sent to all administrators.";
sendEmail('kpeterson5@edison.edu', $subject, $body);
sendEmail('tjbebon@edison.edu', $subject, $body);

$sql = "INSERT INTO `tbSBuildingReports` VALUES (null, :uname, :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :notes, :dateW, :dateL, :curD, :curT)";

db::Query($sql, array(':uname'=>$USER['sUname'], ':a'=>$_POST['s112'], ':b'=>$_POST['fprint'], ':c'=>$_POST['fprintpaper'], ':d'=>$_POST['reg'], ':e'=>$_POST['regpaper'], ':f'=>$_POST['advising'], ':g'=>$_POST['s112details'], ':h'=>$_POST['fprintdetails'], ':i'=>$_POST['fprintpaperdetails'], ':j'=>$_POST['regdetails'], ':k'=>$_POST['regpaperdetails'], ':l'=>$_POST['advisingdetails'], ':notes'=>$_POST['notes'], ':dateW'=>date('W'), ':dateL'=>date("l"), ':curD'=>getCurrentDate(), ':curT'=>getCurrentTime()));
$_GET['msg'] = "Your S-Building Report Was Sent Successfully!";
}
?>
<h1>S-Building Control Center</h1>
<p>
<h4>Submit S-Building Report</h4>
<form action="" method="POST">
<table width="100%">
    <tr>
        <td>1. Were all the machines in S-112 working?</td>
        <td align="right"><input type="radio" id="s112" name="s112" value="Yes" onClick="document.getElementById('s112detailsdiv').style.display = 'none'"> Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="s112" value="No" onClick="document.getElementById('s112detailsdiv').style.display = 'block'"> No</td>
    </tr>
    <tr>
        <td colspan="2"><div id="s112detailsdiv" style="display:none; padding-bottom:3px;">Details: <textarea name="s112details" id="s112details" style="width:100%"></textarea></div></td>
    </tr>
    <tr>
        <td>2. Was the pay-for-print machine in S-112 working?</td>
        <td align="right"><input type="radio" id="fprint" name="fprint" value="Yes" onClick="document.getElementById('fprintdetailsdiv').style.display = 'none'"> Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="fprint" value="No" onClick="document.getElementById('fprintdetailsdiv').style.display = 'block'"> No</td>
    </tr>
    <tr>
        <td colspan="2"><div id="fprintdetailsdiv" style="display:none; padding-bottom:3px;">Details: <textarea name="fprintdetails" id="fprintdetails" style="width:100%"></textarea></div></td>
    </tr>
    <tr>
        <td>3. Did you add paper to the printer in S-112?</td>
        <td align="right"><input type="radio" id="fprintpaper" name="fprintpaper" value="Yes" onClick="document.getElementById('fprintpaperdetailsdiv').style.display = 'none'"> Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="fprintpaper" value="No" onClick="document.getElementById('fprintpaperdetailsdiv').style.display = 'block'"> No</td>
    </tr>
    <tr>
        <td colspan="2"><div id="fprintpaperdetailsdiv" style="display:none; padding-bottom:3px;">Why Not?: <textarea name="fprintpaperdetails" id="fprintpaperdetails" style="width:100%"></textarea></div></td>
    </tr>
    <tr>
        <td>4. Did you add paper to the printer in registration?</td>
        <td align="right"><input type="radio" id="regpaper" name="regpaper" value="Yes" onClick="document.getElementById('regpaperdetailsdiv').style.display = 'none'"> Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="regpaper" value="No" onClick="document.getElementById('regpaperdetailsdiv').style.display = 'block'"> No</td>
    </tr>
    <tr>
        <td colspan="2"><div id="regpaperdetailsdiv" style="display:none; padding-bottom:3px;">Why Not?: <textarea name="regpaperdetails" id="regpaperdetails" style="width:100%"></textarea></div></td>
    </tr>
    <tr>
        <td>5. Were all the registration machines upstairs working?</td>
        <td align="right"><input type="radio" id="reg" name="reg" value="Yes" onClick="document.getElementById('regdetailsdiv').style.display = 'none'"> Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="reg" value="No" onClick="document.getElementById('regdetailsdiv').style.display = 'block'"> No</td>
    </tr>
    <tr>
        <td colspan="2"><div id="regdetailsdiv" style="display:none; padding-bottom:3px;">Details: <textarea name="regdetails" id="regdetails" style="width:100%"></textarea></div></td>
    </tr>
    <tr>
        <td>6. Was the advising queue machine refreshing properly?</td>
        <td align="right"><input type="radio" id="advising" name="advising" value="Yes" onClick="document.getElementById('advisingdetailsdiv').style.display = 'none'"> Yes&nbsp;&nbsp;&nbsp;<input type="radio" name="advising" value="No" onClick="document.getElementById('advisingdetailsdiv').style.display = 'block'"> No</td>
    </tr>
    <tr>
        <td colspan="2"><div id="advisingdetailsdiv" style="display:none; padding-bottom:3px;">Details: <textarea name="advisingdetails" id="advisingdetails" style="width:100%"></textarea></div></td>
    </tr>
    <tr>
        <td>Notes:</td>
        <td align="right"></td>
    </tr>
    <tr>
        <td colspan="2"><textarea id="notes" name="notes" style="width:100%"></textarea></td>
    </tr>
    <tr>
        <td colspan="2" align="center"><input type="submit" value="Submit"></td>
    </tr>
</table>
</form>
<?php
include("template_bot.php");
?>